package com.erp.pro.controller;

import com.erp.common.utils.PageUtils;
import com.erp.common.utils.Query;
import com.erp.pro.domain.ProductQtyDO;
import com.erp.pro.service.ProductQtyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Auther: Eric
 * @Date: 2019/11/3 19:24
 * @Description:
 */
@Controller
@RequestMapping("/pro/productQty")
public class ProductQtyController {

    @Autowired
    private ProductQtyService productQtyService;

    @GetMapping()
    String ProductQty(){
        return "pro/productQty/productQty";
    }

    @ResponseBody
    @GetMapping("/list")
    public PageUtils list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<ProductQtyDO> productQtyList = productQtyService.list(query);
        int total = productQtyService.count(query);
        PageUtils pageUtils = new PageUtils(productQtyList, total);
        return pageUtils;
    }

    @ResponseBody
    @GetMapping("/listBySku")
    public List<ProductQtyDO> listBySku(String sku){
        List<ProductQtyDO> productQtyList = productQtyService.listBySku(sku);
        return productQtyList;
    }

    @GetMapping("/qtylistbysku/{proId}")
    String edittab(@PathVariable("proId") Long proId, Model model){
        model.addAttribute("proId",proId);
        return "pro/productQty/qtylistbysku";
    }

    @ResponseBody
    @GetMapping("/qtylist")
    public PageUtils qtylist(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<ProductQtyDO> productQtyList = productQtyService.list(query);
        int total = productQtyService.count(query);
        PageUtils pageUtils = new PageUtils(productQtyList, total);
        return pageUtils;
    }

    @GetMapping("/warinfo/{warid}")
    String warinfo(@PathVariable("warid") Long warid, Model model){
        model.addAttribute("warid",warid);
        return "pro/productQty/warinfo";
    }

    @ResponseBody
    @GetMapping("/warlist")
    public PageUtils warlist(@RequestParam Map<String, Object> params){
        //查询列表数据
        params.put("qty1","qty1");
        Query query = new Query(params);
        List<ProductQtyDO> productQtyList = productQtyService.list(query);
        int total = productQtyService.count(query);
        PageUtils pageUtils = new PageUtils(productQtyList, total);
        return pageUtils;
    }


}
